var tabs = document.querySelectorAll(".nvzhuangTab");  //获取女装的tab切换
// tab切换 - 切换商品 - 女装

tabs.forEach(function (v, i) {
    v.onmouseover = function () {
        paiT(tabs);
        v.className = "tab redTab";
        if (i == 0) {
            Shangps.innerHTML = "";
            // Rig(women.LianYiQ);  //渲染连衣裙
            Rigccc(allObj.clothingData);
            jsks();
        } else
            if (i == 1) {
                Shangps.innerHTML = "";
                Rig(women.Leis);  //渲染蕾丝
            } else
                if (i == 2) {
                    Shangps.innerHTML = "";
                    Rig(women.Tix);  //渲染T恤
                }
        if (i == 3) {
            Shangps.innerHTML = "";
            Rig(women.Bans);  //渲染半身裤
        }
        if (i == 4) {
            Shangps.innerHTML = "";
            Rig(women.Xiux);  //渲染休闲裤
        }
    }
})


var nanztab = document.querySelectorAll(".nanzhuangTab");  //获取男装的tab切换
// tab切换 - 切换商品 - 男装
nanztab.forEach(function (v, i) {
    v.onmouseover = function () {
        paiT(nanztab);
        v.className = "tab redTab";
        if (i == 0) {
            nanzSp.innerHTML = "";
            Rign(man.Tix);  //渲染T恤
        } else
            if (i == 1) {
                nanzSp.innerHTML = "";
                Rign(man.Kuz);  //渲染裤子
            } else
                if (i == 2) {
                    nanzSp.innerHTML = "";
                    Rign(man.Xiux);  //渲染休闲裤
                }
    }
})

var peijtab = document.querySelectorAll(".peijianTab");  //获取配件的tab切换
// tab切换 - 切换商品 - 配件
peijtab.forEach(function (v, i) {
    v.onmouseover = function () {
        paiT(peijtab);
        v.className = "tab redTab";
        if (i == 0) {
            peijSp.innerHTML = "";
            Rigp(clo.Peij);  //渲染配饰
        } else
            if (i == 1) {
                peijSp.innerHTML = "";
                Rigp(clo.Bangq);  //渲染棒球帽
            } else
                if (i == 2) {
                    peijSp.innerHTML = "";
                    Rigp(clo.Zhey);  //渲染遮阳帽
                }
    }
})

var neiytab = document.querySelectorAll(".neiyiTab");  //获取内衣的tab切换
// tab切换 - 切换商品 - 内衣
neiytab.forEach(function (v, i) {
    v.onmouseover = function () {
        paiT(neiytab);
        v.className = "tab redTab";
        if (i == 0) {
            neiySp.innerHTML = "";
            Rigy(under.Neiy);  //渲染内衣配件
        } else
            if (i == 1) {
                neiySp.innerHTML = "";
                Rigy(under.Neik);  //渲染女式内裤
            } else
                if (i == 2) {
                    neiySp.innerHTML = "";
                    Rigy(under.Liank);  //渲染连袜裤/丝袜
                }
    }
})

var yundtab = document.querySelectorAll(".yundongTab");  //获取运动户外的tab切换
// tab切换 - 切换商品 - 运动户外
yundtab.forEach(function (v, i) {
    v.onmouseover = function () {
        paiT(yundtab);
        v.className = "tab redTab";
        if (i == 0) {
            yundSp.innerHTML = "";
            Rigd(exer.Paob);  //渲染跑步运动
        } else
            if (i == 1) {
                yundSp.innerHTML = "";
                Rigd(exer.Wud);  //渲染舞蹈运动
            } else
                if (i == 2) {
                    yundSp.innerHTML = "";
                    Rigd(exer.Yvj);  //渲染瑜伽运动
                }
    }
})

// 排他思想 - tab切换
function paiT(arr) {
    arr.forEach(function (v, i) {
        v.className = "tab"
    })
}

// 渲染商品 - 女装
var Shangps = document.querySelector(".nvzhuangS");  //商品展示框架
function Rig(arr) {
    for (let i = 0; i < arr.length; i++) {
        // console.log(arr[i]);
        RRig(Shangps, arr[i]);
        // RRigss(Shangps,arr[i]);
    }
}

// 渲染商品 - 男装
var nanzSp = document.querySelector(".nanzhuangS");  //商品展示框架
function Rign(arr) {
    for (let i = 0; i < arr.length; i++) {
        // console.log(arr[i]);
        RRig(nanzSp, arr[i]);
    }
}

// 渲染商品 - 配件
var peijSp = document.querySelector(".peijianS");  //配件展示框架
function Rigp(arr) {
    for (let i = 0; i < arr.length; i++) {
        // console.log(arr[i]);
        RRig(peijSp, arr[i]);
    }
}

// 渲染商品 - 内衣
var neiySp = document.querySelector(".neiyiS");  //配件展示框架
function Rigy(arr) {
    for (let i = 0; i < arr.length; i++) {
        // console.log(arr[i]);
        RRig(neiySp, arr[i]);
    }
}

// 渲染商品 - 运动户外
var yundSp = document.querySelector(".yundongS");  //配件展示框架
function Rigd(arr) {
    for (let i = 0; i < arr.length; i++) {
        // console.log(arr[i]);
        RRig(yundSp, arr[i]);
    }
}

// 追加元素 - 追加商品
function RRig(datx, v) {
    datx.innerHTML += "";
    datx.innerHTML += `
    <div class="shangp">
    <a href="#21">
        <div class="sp_img">
            <img width="100%" src="`+ v.Img + `" alt="">
        </div>
        <p class="sp_wzms">`+ v.name + `</p>
        <p class="sp_jiag">`+ v.price + `</p>
    </a>
    </div>
    `
}

// 额外的追加 - 追加女装 - 连衣裙
var Shangps = document.querySelector(".nvzhuangS");  //商品展示框架
function Rigccc(arr) {
    for (let i = 0; i < arr.length; i++) {
        RRigss(Shangps, arr[i]);
    }
}

function RRigss(datx, v) {
    datx.innerHTML += "";
    datx.innerHTML += `
    <div class="shangp" data-id="`+v.id+`">
    <a href="#21">
        <div class="sp_img">
            <img width="100%" src="`+ v.data.src + `" alt="">
        </div>
        <p class="sp_wzms">`+ v.data.name + `</p>
        <p class="sp_jiag">`+ "¥" + v.data.old + `</p>
    </a>
    </div>
    `
}

// 渲染图标 - 女装
var icos = document.querySelector(".nvzhuangico");  //图标展示框架
function Ricos(arr) {
    for (let i = 0; i < arr.length; i++) {
        // console.log(arr[i]);
        Rico(icos, arr[i]);
    }
}

// 渲染图标 - 女装
var icosn = document.querySelector(".nanzhuangico");  //图标展示框架
function Ricosn(arr) {
    for (let i = 0; i < arr.length; i++) {
        // console.log(arr[i]);
        Rico(icosn, arr[i]);
    }
}

// 渲染图标 - 配件
var icosp = document.querySelector(".peijianico");  //图标展示框架
function Ricosp(arr) {
    for (let i = 0; i < arr.length; i++) {
        // console.log(arr[i]);
        Rico(icosp, arr[i]);
    }
}

// 渲染图标 - 内衣
var icosy = document.querySelector(".neiyiico");  //图标展示框架
function Ricosy(arr) {
    for (let i = 0; i < arr.length; i++) {
        // console.log(arr[i]);
        Rico(icosy, arr[i]);
    }
}

// 渲染图标 - 户外
var icosd = document.querySelector(".yundongico");  //图标展示框架
function Ricosd(arr) {
    for (let i = 0; i < arr.length; i++) {
        // console.log(arr[i]);
        Rico(icosd, arr[i]);
    }
}

// 追加元素 - 追加图标
function Rico(datx, v) {
    datx.innerHTML += "";
    datx.innerHTML += `
    <div class="icoxx">
        <a href="#21">
            <img width="100%" src="`+ v.Img + `" alt="">
        </a>
    </div>
    `
}


// 轮播图追加里面的内容 - 底部
var li1 = document.querySelector(".li111");
var li2 = document.querySelector(".li222");
var li3 = document.querySelector(".li333");

function lunBzui(datx, arr) {
    arr.forEach(function (v, i) {
        datx.innerHTML += `
        <div class="d_li_div">
        <div class="li_div_img">
            <a href="#21">
                <img width="100%" src="`+ v.Img + `" alt="">
            </a>
        </div>
        <div class="li_div_jiag">`+ v.price + `</div>
        <div class="li_div_miaos">`+ v.name + `</div>
        <div class="chakan">查看详细</div>
        </div>
        `
    })
}

// 轮播按钮切换
var liis = document.querySelectorAll(".lunbo_d_ul_li");  //获取三页(底部轮播三页)
var ulls = document.querySelector(".lunbo_d_ul"); //获取轮播的ul

var lefan = document.querySelector(".lefff");  //获取左点击切换按钮
var rigan = document.querySelector(".riggg");  //获取右点击切换按钮

var indexID = 0;

// 右点击
rigan.onclick = function () {
    indexID++;
    console.log(indexID);
    if (indexID < liis.length) {
        ulls.style.left = indexID * -1200 + "px";
    } else {
        indexID = liis.length - 1;
        console.log("后面没有了哟!!!");
    }
    // 焦点
    if (indexID == 0) {
        Jiaodp();
        jiaoD[0].className = "jiaodian redjiaoD"
    } else
        if (indexID == 1) {
            Jiaodp();
            jiaoD[1].className = "jiaodian redjiaoD"
        } else
            if (indexID == 2) {
                Jiaodp();
                jiaoD[2].className = "jiaodian redjiaoD"
            }
}

// 左点击
lefan.onclick = function () {
    indexID--;
    console.log(indexID);
    if (indexID > 0) {
        ulls.style.left = indexID * -1200 + "px";
    } else {
        indexID = 0;
        ulls.style.left = "0px";
        console.log("前面没有了哟!!!");
    }
    // 焦点
    if (indexID == 0) {
        Jiaodp();
        jiaoD[0].className = "jiaodian redjiaoD";
    } else
        if (indexID == 1) {
            Jiaodp();
            jiaoD[1].className = "jiaodian redjiaoD";
        } else
            if (indexID == 2) {
                Jiaodp();
                jiaoD[2].className = "jiaodian redjiaoD";
            }
}

// 焦点 - 变化
var jiaoD = document.querySelectorAll(".jiaodian");

jiaoD.forEach(function (v, i) {
    v.onmouseover = function () {
        if (i == 0) {
            Jiaodp();
            indexID = 0;
            ulls.style.left = "0px";
            jiaoD[0].className = "jiaodian redjiaoD";
        } else
            if (i == 1) {
                Jiaodp();
                indexID = 1;
                ulls.style.left = "-1200px";
                jiaoD[1].className = "jiaodian redjiaoD";
            } else
                if (i == 2) {
                    Jiaodp();
                    indexID = 2;
                    ulls.style.left = "-2400px";
                    jiaoD[2].className = "jiaodian redjiaoD";
                }
    }
})

// 排他 - 底部的轮播图排他
function Jiaodp() {
    jiaoD.forEach(function (v, i) {
        v.className = "jiaodian";
    })
}

var lunBhz = document.querySelector(".lunbo_d");

// 悬浮在轮播图 - 按钮显示
lunBhz.onmouseover = function () {
    lefan.style.display = "block";
    rigan.style.display = "block";
}

// 悬浮在轮播图 - 按钮隐藏
lunBhz.onmouseout = function () {
    lefan.style.display = "none";
    rigan.style.display = "none";
}

// 轮播图追加里面的内容 - 顶部
var liDing1 = document.querySelector(".liding1");
var liDing2 = document.querySelector(".liding2");
var liDing3 = document.querySelector(".liding3");
var liDing4 = document.querySelector(".liding4");
var liDing5 = document.querySelector(".liding5");

function lunBzuiD(datx, arr) {
    arr.forEach(function (v, i) {
        datx.innerHTML += `
        <a href="#21">
        <img width="100%" src="`+ v.Img + `" alt="">
    </a>
        `
    })
}

var lisDing = document.querySelectorAll(".Lun_ul_li");  //获取轮播图片张数
var lisxiab = document.querySelectorAll(".xiabiaoD");  //获取轮播下标

// 排他 - 顶部的轮播图排他
function dingBpait() {
    lisDing.forEach(function (v, i) {
        v.style.opacity = "0";
    })
}

// 排他 - 顶部的轮播图下标排他
function dingBxiabpait() {
    lisxiab.forEach(function (v, i) {
        v.className = "xiabiaoD";
    })
}

// 第一张默认显示 - 顶部轮播
lisDing[0].style.opacity = "1";

// 自动轮播(渐变的效果)
var setID;
var indexIDD = 0;
setID = setInterval(function () {
    indexIDD++;
    // console.log("第" + indexIDD + "张");
    if (indexIDD == 1) {
        dingBpait();
        dingBxiabpait();
        lisDing[0].style.opacity = "1";
        lisxiab[0].className = "xiabiaoD redDiv";
    } else
        if (indexIDD == 2) {
            dingBpait();
            dingBxiabpait();
            lisDing[1].style.opacity = "1";
            lisxiab[1].className = "xiabiaoD redDiv";
        } else
            if (indexIDD == 3) {
                dingBpait();
                dingBxiabpait();
                lisDing[2].style.opacity = "1";
                lisxiab[2].className = "xiabiaoD redDiv";
            } else
                if (indexIDD == 4) {
                    dingBpait();
                    dingBxiabpait();
                    lisDing[3].style.opacity = "1";
                    lisxiab[3].className = "xiabiaoD redDiv";
                } else
                    if (indexIDD == 5) {
                        indexIDD = 0;
                        dingBpait();
                        dingBxiabpait();
                        lisDing[4].style.opacity = "1";
                        lisxiab[4].className = "xiabiaoD redDiv";
                    }
}, 3000);

// 悬浮在下标的时候切换轮播页 - 顶部
lisxiab.forEach(function (v, i) {
    v.onmouseover = function () {
        if (i == 0) {
            indexIDD = 0;
            dingBpait();
            dingBxiabpait();
            lisDing[0].style.opacity = "1";
            lisxiab[0].className = "xiabiaoD redDiv";
        } else
            if (i == 1) {
                indexIDD = 1;
                dingBpait();
                dingBxiabpait();
                lisDing[1].style.opacity = "1";
                lisxiab[1].className = "xiabiaoD redDiv";
            } else
                if (i == 2) {
                    indexIDD = 2;
                    dingBpait();
                    dingBxiabpait();
                    lisDing[2].style.opacity = "1";
                    lisxiab[2].className = "xiabiaoD redDiv";
                } else
                    if (i == 3) {
                        indexIDD = 3;
                        dingBpait();
                        dingBxiabpait();
                        lisDing[3].style.opacity = "1";
                        lisxiab[3].className = "xiabiaoD redDiv";
                    } else
                        if (i == 4) {
                            indexIDD = 4;
                            dingBpait();
                            dingBxiabpait();
                            lisDing[4].style.opacity = "1";
                            lisxiab[4].className = "xiabiaoD redDiv";
                        }
    }
})

// 顶部悬浮的小图标追加 - 导航栏悬浮出来的
var nvzhuangicoDing = document.querySelector(".nvzhuangtubb");  //女装的图标
var nanzhuangicoDing = document.querySelector(".nanzhuangtubb");  //男装的图标
var fushiicoDing = document.querySelector(".fushitubb");  //服饰的图标
var neiyiicoDing = document.querySelector(".neiyitubb");  //内衣的图标
var huwaiicoDing = document.querySelector(".huwaitubb");  //户外的图标

// 追加悬浮内容的小图标 - 追加元素 - 小图标 - 顶部悬浮出的
function Addxuanf(datx, arr) {
    arr.forEach(function (v, i) {
        datx.innerHTML += `
        <div class="nr_rig_ico">
        <img width="100%" src="`+ v.Img + `" alt="">
        </div>
    `
    })
}

// 楼层导航 - tab切换 

var cedaoLs = document.querySelectorAll(".louc_div"); //获取楼层导航的所有小楼层

// 点击楼层进行切换
cedaoLs.forEach(function (v, i) {
    v.onclick = function () {
        if (i == 0) { //限时抢购
            scroll(0, 640);
            loucPait();
            cedaoLs[0].className = "louc_div louceng_xuanz";
        } else
            if (i == 1) { //女装服务
                scroll(0, 720);
                loucPait();
                cedaoLs[1].className = "louc_div louceng_xuanz";
            } else
                if (i == 2) { //男装
                    scroll(0, 1530);
                    loucPait();
                    cedaoLs[2].className = "louc_div louceng_xuanz";
                } else
                    if (i == 3) { //配件服饰
                        scroll(0, 2340);
                        loucPait();
                        cedaoLs[3].className = "louc_div louceng_xuanz";
                    } else
                        if (i == 4) { //内衣
                            scroll(0, 3150);
                            loucPait();
                            cedaoLs[4].className = "louc_div louceng_xuanz";
                        } else
                            if (i == 5) { //运动户外
                                scroll(0, 3960);
                                loucPait();
                                cedaoLs[5].className = "louc_div louceng_xuanz";
                            } else
                                if (i == 6) { //随手购
                                    scroll(0, 4770);
                                    loucPait();
                                    cedaoLs[6].className = "louc_div louceng_xuanz";
                                }
    }
})

// 楼层选中排他
function loucPait() {
    cedaoLs.forEach(function (v, i) {
        v.className = "louc_div"
    })
}

var loucZHU = document.querySelector(".louceng");

// 定时器测量坐标
setInterval(function () {
    var Top = document.documentElement.scrollTop;
    // console.log(Top);  //浏览器的坐标位置(Y轴 - top)
    // 楼层跳跃
    if (Top == 640 || Top < 720) {
        loucPait();
        cedaoLs[0].className = "louc_div louceng_xuanz";
    } else
        if (Top == 72 || Top < 1530) {
            loucPait();
            cedaoLs[1].className = "louc_div louceng_xuanz";
        } else
            if (Top == 1530 || Top < 2340) {
                loucPait();
                cedaoLs[2].className = "louc_div louceng_xuanz";
            } else
                if (Top == 2340 || Top < 3150) {
                    loucPait();
                    cedaoLs[3].className = "louc_div louceng_xuanz";
                } else
                    if (Top == 3150 || Top < 3960) {
                        loucPait();
                        cedaoLs[4].className = "louc_div louceng_xuanz";
                    } else
                        if (Top == 3960 || Top < 4770) {
                            loucPait();
                            cedaoLs[5].className = "louc_div louceng_xuanz";
                        } else
                            if (Top == 4770 || Top < 5243) {
                                loucPait();
                                cedaoLs[6].className = "louc_div louceng_xuanz";
                            }
    // 大盒子隐藏与显示
    if (Top >= 640) {
        // loucZHU.style.opacity="1";
        // loucZHU.style.display="block";
        loucZHU.className = "louceng";
    } else {
        // loucZHU.style.opacity="0";
        // loucZHU.style.display="none";
        loucZHU.className = "louceng_b";
    }
    // 监听浏览器宽度 - 对象相对于版面的左侧宽距离
    var lunbCe = document.querySelector(".Daohang_ce");
    var lefT = lunbCe.offsetLeft;  //一直监听居中元素距离浏览器最左边(版面)的距离
    // console.log(lefT);
    loucZHU.style.left = (lefT - 50) + "px";
}, 100);


// 
Rigccc(allObj.clothingData);  //渲染连衣裙



// 




// -------------------------------------------------------------------------------------


// 购物车系列
var xiaoyuand = document.querySelector(".cxdsp"); //小圆点(数量)
var gouwuc = document.querySelector(".cxdli3");   //购物车 (单独的点击块)

gouwuc.onmouseover = function () {  //悬浮的时候购物车样式
    xiaoyuand.style.backgroundColor = "#fff";
    xiaoyuand.style.color = "#f42424";
}
gouwuc.onmouseout = function () {  //离开的时候购物车样式
    xiaoyuand.style.backgroundColor = "#f42424";
    xiaoyuand.style.color = "#fff";
}

// 购物车展开问题
var gouwuczhans = document.querySelector(".gouwu_zhans");  //获取购物车展示区域(展示)
var cebiangouwc = document.querySelector(".publicAich");  //侧边购物车栏
var gouwucjiesu = document.querySelector(".gouwu_jiesuan"); //购物车展示区域的结算区
var gouwugouwuw = document.querySelector(".gouw"); //购物车(全部)

var idd = 0;  //点击次数
gouwuc.onclick = function () {
    idd++;
    if (idd % 2 == 0) {
        cebiangouwc.style.right = "0px";
        gouwugouwuw.style.right = "-280px";
        gouwucjiesu.style.right = "-280px";
    } else {
        cebiangouwc.style.right = "280px";
        gouwugouwuw.style.right = "0px";
        gouwucjiesu.style.right = "0px";
    }
}

// 点击关闭购物车 - 关闭按钮
var guanbianniu = document.querySelector(".bi-x-circle"); //获取关闭购物车的按钮

guanbianniu.onclick = function () {
    idd++;
    cebiangouwc.style.right = "0px";
    gouwugouwuw.style.right = "-280px";
    gouwucjiesu.style.right = "-280px";
}
// 购物车 - 添加删除





// 购物车事件
function Gouwcz(datx) {
    datx.innerHTML += `
    <div class="cart-block" data-id="`+v.id+`">
		<div class="checkbox-wrap">
			<img src="../images/tick.png" class="tick">
			<input type="checkbox" name="" id="" value="" class="checkbox mycheckbox"/>
		</div>
		<img src="`+ v.data.src + `" class="cart-goods-img">
		<div class="cart-goods-info">
			<p class="cart-goods-name">`+ v.data.title + `</p>
			<p class="cart-goods-sku del">
                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16">
                <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
                <path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/>
                </svg>
            </p>
			<div class="price-wrap">
				<span>￥<span class="price">`+ v.data.new + `</span></span>
				<div class="num-wrap">
					<img src="http://127.0.0.1:8848/%E5%8A%A0%E5%85%A5/images/sub.png" class="sub">
					<input type="number" name="" id="num-input" class="num-input" value="1" readonly/>
					<img src="http://127.0.0.1:8848/%E5%8A%A0%E5%85%A5/images/add.png" class="add">
				</div>
			</div>
		</div>
	</div>
    `
}

// 购物车事件
var checkboxLen;
var checkedLen = 0;
$(function () {
    var checkbox = document.getElementsByClassName('mycheckbox')
    checkboxLen = checkbox.length;
})

// 多选框-统一
$(document).on('click', '.checkbox', function () {
    if ($(this)[0].checked) {
        // 需变 选中
        $(this).prev().attr('src', '');
    } else {
        // 需变 不选中
        $(this).prev().attr('src', '');
    }
})


// 多选框-上面
$(document).on('click', '.mycheckbox', function () {
    checkedLen = 0;
    $(".mycheckbox").each(function (index, item) {
        if ($(this)[0].checked) {
            checkedLen++
        }
    });
    $(".checkedLen").html(checkedLen);
    if (checkedLen == checkboxLen) {
        $(".allselect").prop('checked', true);
        $(".allselect").prev().attr('src', '');
    } else {
        $(".allselect").prop('checked', false);
        $(".allselect").prev().attr('src', '');
    }
    total();
})

// 多选框-全选
$(document).on('click', '.allselect', function () {
    if ($(this)[0].checked) {
        // 需变 选中
        $('.tick').attr('src', '');
        $('.checkbox').prop('checked', true);
    } else {
        // 需变 不选中
        $('.tick').attr('src', '');
        $('.checkbox').prop('checked', false);
    }
    checkedLen = 0;
    $(".mycheckbox").each(function (index, item) {
        if ($(this)[0].checked) {
            checkedLen++
        }
    });
    $(".checkedLen").html(checkedLen);
    total();
})


// 统计金额
function total() {
    var integer = 0;
    $(".mycheckbox").each(function (index, item) {
        if ($(this)[0].checked) {
            var price = Number($(this).parents('.cart-block').find('.price').html().substring(0));
            var num = $(this).parents('.cart-block').find('.num-input').val();
            integer += price * num;
            console.log(price);
        }
    });
    integer = Math.floor(integer * 100) / 100;
    if (isInteger(integer)) {
        $('.integer').html(integer);
        $('.point').html('');
        return;
    }
    var str = integer.toString();
    var index = str.indexOf(".");
    var result = str.substring(index + 1, str.length);
    var integerStr = str.substring(0, index);
    console.log(index);
    console.log(integerStr);
    $('.integer').html(integerStr);
    $('.point').html('.' + result);
}


// 数量增减
$(document).on('click', '.sub', function () {
    var val = $(this).parent().find('.num-input').val();
    if (val == 1) {
        return;
    }
    var num = Number(val) - 1;
    $(this).parent().find('.num-input').val(num);
    total();
})

$(document).on('click', '.add', function () {
    var val = $(this).parent().find('.num-input').val();
    var num = Number(val) + 1;
    $(this).parent().find('.num-input').val(num);
    total();
})

function isInteger(obj) {
    return obj % 1 === 0
}


// 编辑
$(document).on('click', '.cart-operation', function () {
    if ($(this).hasClass('edit')) {
        $(this).removeClass('edit');
        $(this).addClass('delete');
        $('.settlement').hide();
        $('.delete-btn').show();
        $(this).html('完成');
    } else {
        $('.settlement').css('display', 'flex');
        $('.delete-btn').hide();
        $(this).addClass('edit');
        $(this).removeClass('delete');
        $(this).html('编辑');
    }
})

// ------------------------ 传输数据 ---------------------------------//

// console.log($(".shangp"));

var idc;
// 点击加入本地存储
function jsks() {
    $(".shangp").each(function(i,v){
        $(v).on("click",function(){
            idc = $(this).attr("data-id");
            // console.log(idc);
            var objx = localStorage.setItem("id"+idc,idc);
            // console.log(objx);
    
            var strx = localStorage.getItem("id"+idc);
            // console.log(strx);
            // $('.gouwu_zhans').html("");
            sjsjs();
        })
    })
}

jsks();

// //  获取其他页面传入数据
let dataage = window.localStorage;
// console.log(dataage);
// console.log(dataage.id);
//获取所有数据
let allData = allObj.clothingData;
// console.log(allobj);
// console.log(allData);
//筛选数据
var arrNew = new Array;
for (let k in dataage) {
    arrNew.push(k);
    // console.log(k);
}
arrNew.splice(arrNew.length - 6, 6);
var newData = new Array;
arrNew.map(function(value, i) {
    return newData.push(allData.filter(function(v, i) {
        return value.slice(2, 7) == v.id;
    }));
})
// console.log(newData);
var x = newData.flat();
// console.log(x);

sjsjs();

function sjsjs() {
    // $('.gouwu_zhans').html("");
    $(x).each(function(i, v) {
        // console.log(v.data.name);
        $('.gouwu_zhans').append($('<div class="cart-block" data-id="'+v.id+'"><div class="checkbox-wrap"><img src="../images/tick.png" class="tick"><input type="checkbox" name="" id="" value="" class="checkbox mycheckbox"/></div><img src="'+ v.data.src + '" class="cart-goods-img"><div class="cart-goods-info"><p class="cart-goods-name">'+ v.data.name + '</p><p class="cart-goods-sku del"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/><path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/></svg></p><div class="price-wrap"><span><span class="jinqqqq">￥</span><span class="price">'+ v.data.old + '</span></span><div class="num-wrap"><img src="img/sub.png" class="sub"><input type="number" name="" id="num-input" class="num-input" value="1" readonly/><img src="img/add.png" class="add"></div></div></div></div>'))
    
        // 商品数量变化
        $(".cxdsp").html($(".cart-block").length);
        $(".shangpinsl").html($(".cart-block").length);
        // 有商品的时候 - 小鸟消失
        if ($(".cart-block").length>0) {
            $(".zhans_xiaon").css("display","none");
        }else{
            $(".zhans_xiaon").css("display","flex");
        }
    })
}

// console.log($(".zhans_xiaon"));

// 删除 - 删除商品 - 同时删除本地存储的数据
$(".del").each(function(i,v){
    $(v).on("click change",function(){
        var bendiid = $(this).parent().parent().attr("data-id");
        $(this).parent().parent().remove();
        localStorage.removeItem("id"+bendiid);

        // 商品数量变化
        $(".cxdsp").html($(".cart-block").length);
        $(".shangpinsl").html($(".cart-block").length);
        // 有商品的时候 - 小鸟消失
        if ($(".cart-block").length>0) {
            $(".zhans_xiaon").css("display","none");
        }else{
            $(".zhans_xiaon").css("display","flex");
        }
        total();
        // $('.gouwu_zhans').html("");
    })
})

// console.log($(".shangp"));

$(".shangp").on("click",function(){
    var idds = $(this).attr('data-id');
    // console.log(idds);
    window.localStorage.setItem("id",idds);
    window.localStorage.setItem("index",3);
    window.location.href = "particulars.html";
})
